/**
 * 报表审批公共方法
 */
import {httpAction, getAction, postAction} from '@/api/manage'
export const BbspModelMixin = {
  data() {
    return {
      Loading: false,
      disableSubmit: false,
      dataSource: [],
      title: '',
      visible: false,
      isCheck: false
    }
  },
  mounted() {

  },
  computed: {

  },
  methods: {

    // 关闭报表
    close(isSubmit) {
      if (isSubmit) {
      } else {
        this.visible = false
      }
    },

    // 设置审批原因
    setApproveReason(param){
      this.approveType = param
      this.$refs.setReason.setApproveReason = true
    },

    // 审核数据
    approveData1(data) {
      this.Loading = true
      getAction(this.url.approve, { proId:this.model.id, applyType:this.approveType,type: this.reportType, reason:data }).then((res) => {
        if (res.success) {
          this.$message.success(res.message)
          this.Loading = false
          this.visible = false
          this.$emit('ok')
        } else {
          this.$message.error(res.message)
          this.Loading = false
        }
      })
    },
    // 审核数据
    approveData2(data) {
      this.Loading = true
      getAction(this.url.approve, { proId:this.model.id, state:this.approveType, sjType:this.sjType,reason:data }).then((res) => {
        if (res.success) {
          this.$message.success(res.message)
          this.Loading = false
          this.visible = false
          this.$emit('ok')
        } else {
          this.$message.error(res.message)
          this.Loading = false
        }
      })
    },

    // 获取前两类报表报表表格信息
    getTableData1(){
      getAction(this.url.list, {id:this.model.id, type:this.reportType}).then(res=>{
        if(res.success){
          this.dataSource = JSON.parse(res.result[0].reportInfo)
          this.model.createTime = res.result[0].createTime
          this.model.createByText = res.result[0].createByText
          this.model.auditPersonName = res.result[0].auditPersonName
          this.model.departName = res.result[0].departName
          this.model.year = res.result[0].year
          this.model.quarter = res.result[0].quarter
          this.model.fileId = res.result[0].fileId
          this.Loading = false
        }
      })
    },

    // 保存数据
    getTableData2(){
      getAction(this.url.list,{id:this.model.id}).then(res=>{
        if(res.success){
          this.dataSource = res.result[0].mapInfo
          this.model.createTime = res.result[0].createTime
          this.model.createByText = res.result[0].createByText
          this.model.auditPersonName = res.result[0].headName
          this.model.departName = res.result[0].departName
          this.model.year = res.result[0].year
          this.model.quarter = res.result[0].quarter
          this.model.fileId = res.result[0].fileId
          this.Loading = false
        }
      })
    },

    // 保存数据
    getTableData3(){
      getAction(this.url.list,{id:this.model.id}).then(res=>{
        if(res.success){
          this.dataSource = JSON.parse(res.result[0].info)
          this.model.createTime = res.result[0].createTime
          this.model.createByText = res.result[0].createByText
          this.model.auditPersonName = res.result[0].headName
          this.model.departName = res.result[0].departName
          this.model.year = res.result[0].year
          this.model.quarter = res.result[0].quarter
          this.model.fileId = res.result[0].fileId
          this.Loading = false
        }
      })
    },
  }

}